<html>
<head>
	<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
	<title>Pages: index</title>
	<link href="/stylesheets/scaffold.css?1183270335" media="screen" rel="Stylesheet" type="text/css" />
	<script src="/javascripts/prototype.js?1183270335" type="text/javascript"></script>
	<script src="/javascripts/effects.js?1183270335" type="text/javascript"></script>
	<script src="/javascripts/dragdrop.js?1183270335" type="text/javascript"></script>
	
	<script src="/javascripts/controls.js?1183270335" type="text/javascript"></script>
	<script src="/javascripts/application.js?1183270335" type="text/javascript"></script>
	<script src="/javascripts/jester.js?1183270335" type="text/javascript"></script>
	<script src="/javascripts/gears_init.js?1183270335" type="text/javascript"></script>
</head>
<body onLoad="init()">
<script>
	var db, pageID = '37';
	init();
	
	// Open this page's local database.
	function init() {
		if (!window.google || !google.gears) {
		    return;
		}
		
		try {
		    db = google.gears.factory.create('springnote', '1.0');
		} catch (ex) {
		    setError('Could not create database: ' + ex.message);
		}
		
		if (db) {
			viewPost();
		}
	}
	
	function viewPost() {
	  try {
		db.open('database-demo');
	    var rs =db.execute('select title contents from Page where pageid = ' +pageID);

		var title = rs.filed('title');
		var contents = rs.filed('contents');
	    rs.close();
	    
	    $('post_title').value = title;
	    $('post_contents').value = contents;
	  } catch (e) {
	    throw new Error(e.message);
	  }	
	}
	
	function saveContents() {
		if (!google.gears.factory || !db) {
			return;
		}
		var title = $('post_title').value;
		var contents = $('post_contents').value;
		
		rs = db.execute('Update Page set title=' +title +' contents=' +contents +' where id=' +pageID);
		rs.close();
		return true;
	}
</script>
<form onsubmit="saveContents();" action="sss.html">
	<h2>Editing Page</h2> 
	<h4>Title</h4>
	<input type="text" size="30" id="post_title">
	<h4>Source</h4>
	<textarea rows="10" cols="25" id="post_contents"></textarea><br>
	<input type="button" value="Update">
</form>
</body>
</html>